package nullby.omnia.adapter;

import java.util.ArrayList;

import nullby.omnia.R;
import nullby.omnia.model.WordOfVoc;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AdapterVocWord extends ArrayAdapter<WordOfVoc> {
	private LayoutInflater inflater;
	private Typeface font;
	private ArrayList<WordOfVoc> objects;

	public AdapterVocWord(Context context, int textViewResourceId,
			ArrayList<WordOfVoc> objects) {
		super(context, textViewResourceId, objects);
		this.objects = objects;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		font = Typeface.createFromAsset(context.getAssets(), "font.ttf");
	}

	@Override
	public View getView(int position, View vi, ViewGroup parent) {
		if (vi == null) {
			vi = inflater.inflate(R.layout.item_voc_word, null);
		}

		TextView tvWord = (TextView) vi.findViewById(R.id.tvWord);

		tvWord.setText(objects.get(position).getWord());

		tvWord.setTypeface(font);

		tvWord.setTag(objects.get(position).getId());
		return vi;
	}

}
